//
//  LoginProtocols.swift
//  MikerShop
//
//  Created by eme on 2016/11/9.
//  Copyright © 2016年 eme. All rights reserved.
//

/*
 owner:cy
 update:2016年11月09日15:24:28
 info: 登陆模块的相关协议
 */
import Foundation
import RxSwift
import RxCocoa

enum ValidationResult {
    case ok(message:String)
    case empty
    case validating
    case failed(message:String)
}

protocol LoginValidationProtocol {
    
    func validateUsername( _ username:String)  -> ValidationResult
    func validatePassword( _ password:String)  -> ValidationResult

}
protocol RegisterValidationProtocol {
    /// 手机号 验证
    func validatePhone( _ username:String)  -> ValidationResult
    /// 短信验证码 合法性验证
    func validateMsgCode( _ msgCode:String)  -> ValidationResult
    /// 邀请码 合法性验证
    func validateRegisterCode( _ registerCode:String)  -> ValidationResult
    /// 企业名称 合法性验证
    func validateCompanyName( _ companyName:String)  -> ValidationResult
    /// 联系人 合法性验证
    func validateContactName( _ contactName:String)  -> ValidationResult
    /// 所在城市 合法性
    func validateCity( _ city:String)  -> ValidationResult
    /// 营业执照 合法性验证
    func validateBslicense( _ bslicense:String)  -> ValidationResult
    /// 密码 合法性验证
    func validatePassword( _ password:String)  -> ValidationResult
    /// 再次密码 合法性验证
    func validateRepeatPassword( _ password:String,repeatPassword:String)  -> ValidationResult

}
extension ValidationResult {
    var isValid: Bool {
        switch self {
        case .ok:
            return true
        default:
            return false
        }
    }
    var notEmpty: Bool {
        switch self {
        case .empty:
            return false
        default:
            return true
        }
    }
    var message:String{
        switch self {
        case .failed(let message):
            return message
        default:
            return ""
        }
    }
}
